package owg.util.opengl.models;

import java.nio.FloatBuffer;

/**
 * This class is a container for a vertex using 32 bit floats for data. 
 * */
public class VertexRawF implements VertexFloat
{
	/**The vertex can be assumed to contain the data, exactly as specified in the array.
	 * The raw data can be assumed to fit into whatever buffer the vertex is to be used for.
	 * The data will be looked up from position "rawDataOffset" and "rawDataLength" number of floats will be used.*/
	public float[] rawData;
	/**The position to look up in the rawData array*/
	public int rawDataOffset;
	/**The number of floats to use in the rawData array*/
	public int rawDataLength;
	
	/**Construct a vertex with raw data.
	 * The user must be careful to design this so that the raw data can be directly copied into whereever it is to be used later.
	 * @param length 
	 * @param position */
	public VertexRawF(float[] rawData, int position, int length)
	{
		this.rawData = rawData;
		this.rawDataOffset = position;
		this.rawDataLength = length;
	}
	@Override
	public VertexRawF clone()
	{
		return new VertexRawF(rawData.clone(), rawDataOffset, rawDataLength);
	}
	public VertexRawF softCopy()
	{
		return new VertexRawF(rawData, rawDataOffset, rawDataLength);
	}
	@Override
	public void put(FloatBuffer buf, int numVertexComponents,
		boolean useNormal, byte numColorComponents, byte numTexCoordComponents,
		byte numTexCoordComponents2)
	{
		buf.put(rawData,rawDataOffset,rawDataLength);
	}
}
